<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>婚姻登记查询</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link rel="stylesheet" type="text/css" href="${contextPath}/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="${contextPath}/css/bootstrap-theme.min.css" />
<link href="${contextPath}/css/jquery-ui.min.css" rel="stylesheet">
<link href="${contextPath}/css/jquery-ui.theme.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="${contextPath}/css/public.css">
<script type="text/javascript" src="${contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${contextPath}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${contextPath}/js/common.js"></script>
<script type="text/javascript" src="${contextPath}/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="${contextPath}/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="${contextPath}/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="${contextPath}/js/jquery.ui.datepicker-ch.js"></script>
</head>
<body>
	<input type="hidden" value="${usertype}" id="usertype"/>
	<div class="container" >
		<div class="panel panel-default">
			<div class="panel-heading">查询列表<span id="taskMarkTimeMonthTotle" class="pull-right text-success">管理员：${sessionScope.username}
			<c:if test="${usertype==0}"> | <a target="_blank" href="${contextPath}/security/manager">用户管理</a></c:if>
			| <a href="${contextPath}/quit">退出</a></span>
			</div>
			<div class="panel-body">
				<div class="form-group">
					<div class="form-inline">
						<div class="input-group">
							<div class="input-group-addon" style="background-color:#91bdf3;color: black; font-weight: bold;">男方姓名：</div>
							<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="man" type="text" >
						</div>
						<div class="input-group">
							<div class="input-group-addon" style="background-color:#91bdf3;color: black; font-weight: bold;"> 男身份证：</div>
							<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="manId" type="text" >
						</div>
						<div class="input-group">
							<div class="input-group-addon" style="background-color:#efadad;color: black; font-weight: bold;">女方姓名：</div>
							<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="woman" type="text" >
						</div>
						<div class="input-group">
							<div class="input-group-addon" style="background-color:#efadad;color: black; font-weight: bold;"> 女身份证：</div>
							<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="womanId" type="text" >
						</div>	
					</div>
				</div>
			    <div class="form-group">
					<div class="form-inline">
						<div class="input-group">
							<div class="input-group-addon" style="background-color:#CCC;color: black; font-weight: bold;">&nbsp;&nbsp;&nbsp;证字号：</div>
							<input class="form-control" onkeydown="if(event.keyCode==13){return false;}" id="marriageId" type="text" >
						</div>
						<div class="input-group">
							<div class="input-group-addon" style="background-color:#CCC;color: black; font-weight: bold;">登记年份：</div>
							<input class="form-control" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="6" onkeydown="if(event.keyCode==13){return false;}" id="marriage-date" type="text" >
						</div>
						<div class="input-group">
							<div class="input-group-addon" style="background-color:#CCC;color: black; font-weight: bold;"> 登记业务：</div>
							<select class="form-control" id="marriageStatus" name="marriageStatus" autocomplete="off">
								<option value="" selected="selected" >全部</option>
								<option value="结婚" >结婚</option>
								<option value="离婚">离婚</option>
								<option value="补领结婚">补领结婚</option>
								<option value="补领离婚">补领离婚</option>
							</select>
						</div>
						
						<button type="button" id="searchBtn" class="btn btn-success">查询</button>
						<c:if test="${usertype==0}">
							<button type="button" id="addMarriageBtn" class="btn btn-warning">添加</button>
							<button type="button" id="batchImportBtn" class="btn btn-primary">批量导入</button>
						</c:if>
						<c:if test="${usertype==1}">
							<button type="button" id="batchImportBtn" class="btn btn-primary">批量导入</button>
						</c:if>
					</div>
				</div>



				<table class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<c:if test="${sessionScope.usertype!=2}">
								<th width='4%'>序号</th>
								<th width='14%'>证字号</th>
								<th width='10%'>登记日期</th>
								<th width='8%'>登记业务</th>
								<th width='8%'>男方姓名</th>
								<th width='12%'>男方身份证号</th>
								<th width='8%'>女方姓名</th>
								<th width='12%'>女方身份证号</th>
								<th width='5%'>查看</th>
								<th width='10%'>操作</th>
							</c:if>
							<c:if test="${sessionScope.usertype==2}">
								<th width='4%'>序号</th>
								<th width='14%'>证字号</th>
								<th width='10%'>登记日期</th>
								<th width='8%'>登记业务</th>
								<th width='8%'>男方姓名</th>
								<th width='12%'>男方身份证号</th>
								<th width='8%'>女方姓名</th>
								<th width='12%'>女方身份证号</th>
								<th width='5%'>查看</th>
							</c:if>
						</tr>
					</thead>
					<tbody></tbody>
			</table>
			<ul class="pagination"></ul>
			</div>
		</div>
	</div>
<!-- 删除模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
            <h4 class="modal-title">重要提示</h4>
         </div>
         <div class="modal-body">确定要删除该条数据？</div>
         <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal">关闭
            </button>
            <button type="button" class="btn btn-primary" id="deleteButton">删除</button>
         </div>
      </div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>	
	
<!-- 导入模态框（Modal） -->
<div class="modal fade" id="import-dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times;</button>
            <h4 class="modal-title">批量导入</h4>
         </div>
         <div class="modal-body">
         	<iframe id="import-iframe" src="/ps/security/import" width="500px;" style="border: 0px;"></iframe>
         </div>
         <div class="modal-footer">
            <button type="button" class="btn btn-default" 
               data-dismiss="modal">关闭
            </button>
         </div>
      </div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>
	<script type="text/javascript">
		var utDropdownOpen = false;
		var nowUserType = 4;
		var nowPage = 0;
		var userNameCondition = "";
		var month = 0;
		var taskUpload = 2;
		var year = 0;
		var userId = 0;
		var pageTotal = 1;
		var deleteUserId=null;
		$(document).ready(function(){
			//$("#marriage-date").datepicker();
			chooseUserType(1);
			/*--------------------------------------点击查询按钮-------------------------------------------------------*/
			$("#searchBtn").click(function(){
				chooseUserType(1);
			});
			$("#addMarriageBtn").click(function(){
				var url = "${contextPath}/security/addMarriage";
				window.open(url,"_blank");
				//location.href=;
			});
			update = function(userId){
				var url = "${contextPath}/security/update?userId="+userId;
				window.open(url,"_blank");
			};
			delBtn = function(id){
				deleteUserId=id;
				$("#myModal").modal('show');
			};
			/*--------------------------------------点击更改用户状态-------------------------------------------------------*/
			getImage = function(userId){
				var url = "${contextPath}/security/getImage?userId="+userId;
				window.open(url,"_blank");
			};
			uploadImage = function(dir,userId){
				var url = "${contextPath}/security/upload?dir="+dir+"&userId="+userId;
				window.open(url,"_blank");
			};
			/*--------------------------------------删除-------------------------------------------------------*/
			$("#deleteButton").click(function(){
				if(deleteUserId!=null){
					$.ajax({
						type:'POST',
						data:{"userId":deleteUserId},
						url:'${contextPath}/security/delMarriage',
						dataType:'json',
						success:function(data){
							chooseUserType(1);
							$("#myModal").modal('hide');
							alert(data.message);
						}
					});
				}
			});

			$("#myModal").on('hide.bs.modal', function () {
      			deleteUserId=null;
      		});
			/*--------------------------------------更改用户状态-------------------------------------------------------*/
			$("#batchImportBtn").click(function(){
				$("#import-iframe").attr("src","/ps/security/import");
				$("#import-dialog").modal('show');
			});
		});

		/*--------------------------------------加载页面-------------------------------------------------------*/
		chooseUserType = function(pageNum){
			var marriageId=$("#marriageId").val();
			var marriageStatus=$("#marriageStatus").val();
			var manId=$("#manId").val();
			var man=$("#man").val();
			var womanId=$("#womanId").val();
			var woman=$("#woman").val();
			var date=$("#marriage-date").val();
			$.ajax({
				type:'POST',
				data:{"marriageId":marriageId,"marriageStatus":marriageStatus,"manId":manId,"man":man,"womanId":womanId,"woman":woman,"date":date,"page":pageNum },
				url:'${contextPath}/security/marriage',
				dataType:'json',
				success:function(data){
					$("tbody").empty();
					if(data.list == ""){
						$("tbody").empty();
						$("tbody").append("<tr class='text-danger'><td colspan='10'>未查询到相关数据</td></tr>");
						alert("未查询到相关信息！");
					}else{
						$.each(data.list,function(i,item){
						var usertype = $("#usertype").val();
						var trCss="";
						if (item.marriageStatus=='结婚'){
							trCss='red';
						}
						if(usertype==0){
							$("tbody").append(
								"<tr>"+
									"<td>"+(i+1)+"</td>"+
									"<td>"+item.marriageId+"</td>"+
									"<td>"+item.marriageDate+"</td>"+
									"<td style=color:"+trCss+">"+item.marriageStatus+"</td>"+
									"<td>"+item.manName+"</td>"+
									"<td>"+item.manId+"</td>"+
									"<td>"+item.womanName+"</td>"+
									"<td>"+item.womanId+"</td>"+
									"<td><a href='javascript:getImage("+item.id+")'>查看["+item.photoPath+"]</a></td>"+
									"<td><a href='javascript:uploadImage(\""+item.photoPath+"\","+item.id+")'>导入</a> | <a href='javascript:update("+item.id+")'>修改</a> | <a href='javascript:delBtn("+item.id+")'>删除</a></td>"+
								"</tr>"
							);
						}else if(usertype==1){
							$("tbody").append(
								"<tr>"+
									"<td>"+(i+1)+"</td>"+
									"<td>"+item.marriageId+"</td>"+
									"<td>"+item.marriageDate+"</td>"+
									"<td style=color:"+trCss+" >"+item.marriageStatus+"</td>"+
									"<td>"+item.manName+"</td>"+
									"<td>"+item.manId+"</td>"+
									"<td>"+item.womanName+"</td>"+
									"<td>"+item.womanId+"</td>"+
									"<td><a href='javascript:getImage("+item.id+")'>查看["+item.photoPath+"]</a></td>"+
									"<td><a href='javascript:uploadImage(\""+item.photoPath+"\","+item.id+")'>导入</a>"+
									"</tr>"
							);
						}else{
							$("tbody").append(
								"<tr>"+
									"<td>"+(i+1)+"</td>"+
									"<td>"+item.marriageId+"</td>"+
									"<td>"+item.marriageDate+"</td>"+
									"<td style=color:"+trCss+" >"+item.marriageStatus+"</td>"+
									"<td>"+item.manName+"</td>"+
									"<td>"+item.manId+"</td>"+
									"<td>"+item.womanName+"</td>"+
									"<td>"+item.womanId+"</td>"+
									"<td><a href='javascript:getImage("+item.id+")'>查看["+item.photoPath+"]</a></td>"+
									"</tr>"
							);						
						
						}

						});
						var pageDom = $(".pagination");
						pageDom.empty();
						pageTotal = data.totlePage;
						page.creatPageHTML(pageNum,pageTotal,pageDom,"chooseUserType");
						/*--------------------------------------跳转页-------------------------------------------------------*/
						$(".pageGoBtn").click(function(){
							var pageNum = 0;
							pageNum = $(".pageGoText").val();
							if(pageNum>pageTotal){
								pageNum = pageTotal;
							}else if(pageNum<1){
								pageNum=1;
							}
							chooseUserType(pageNum);
						});
					}
				}
			});
		};
	</script>
</body>
</html>
